dce-reactkit 5.0.9 → 5.0.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/dist/cjs/index.js +18 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/esm/index.js +15 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/helpers/useBackButton.tsx +20 -1
- package/src/index.ts +2 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { 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, SELECT_ADMIN_CHECK_ROUTE, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, getMondayOfTimestamp, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, extractProp, compareArraysByProp, getLocalTimeInfo, genCommaList, validateEmail, validatePhoneNumber, validateString, idify, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, cloneDeep, getTimestampFromTimeInfoInET, spaceAtCapitals, ParamType, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, LogTypeSpecificInfo, LogMainInfo, LogSourceSpecificInfo, LogLevel, CommonKitErrorCode, LogReviewerFilterState } from 'dce-commonkit';
|
|
1
|
+
import { 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, SELECT_ADMIN_CHECK_ROUTE, abbreviate, avg, ceilToNumDecimals, convertDateKeyToDateInfo, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, getMondayOfTimestamp, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, extractProp, compareArraysByProp, getLocalTimeInfo, genCommaList, validateEmail, validatePhoneNumber, validateString, idify, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, cloneDeep, getTimestampFromTimeInfoInET, spaceAtCapitals, ParamType, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, LogTypeSpecificInfo, LogMainInfo, LogSourceSpecificInfo, LogLevel, CommonKitErrorCode, LogReviewerFilterState } from 'dce-commonkit';
|
|
2
2
|
import AppWrapper, { alert, prompt, confirm, showFatalError, addFatalErrorHandler, leaveToURL } from './components/AppWrapper';
|
|
3
3
|
import LoadingSpinner from './components/LoadingSpinner';
|
|
4
4
|
import ErrorBox from './components/ErrorBox';
|
|
@@ -52,4 +52,4 @@ import PickableItem from './components/ItemPicker/types/PickableItem';
|
|
|
52
52
|
import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
|
|
53
53
|
import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
|
|
54
54
|
import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
|
|
55
|
-
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, SimpleMonthChooser, SimpleTimeChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, ProgressBar, FakeProgressBar, alert, prompt, confirm, showFatalError, DynamicWord, stubServerEndpoint, canReviewLogs, isMobileOrTablet, makeLinksClickable, isSelectAdmin, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, useBackButton, backButtonController, setClientEventMetadataPopulator, ModalButtonType, ModalSize, ModalType, Variant, IntelliTableColumn, DropdownItemType, LogReviewerFilterState, ProgressBarSize, BackState, BackButtonController, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, 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, SELECT_ADMIN_CHECK_ROUTE, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, getMondayOfTimestamp, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, extractProp, compareArraysByProp, getLocalTimeInfo, genCommaList, validateEmail, validatePhoneNumber, validateString, idify, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, cloneDeep, getTimestampFromTimeInfoInET, spaceAtCapitals, ParamType, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, LogTypeSpecificInfo, LogMainInfo, LogSourceSpecificInfo, LogLevel, CommonKitErrorCode, };
|
|
55
|
+
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, SimpleMonthChooser, SimpleTimeChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, ProgressBar, FakeProgressBar, alert, prompt, confirm, showFatalError, DynamicWord, stubServerEndpoint, canReviewLogs, isMobileOrTablet, makeLinksClickable, isSelectAdmin, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, useBackButton, backButtonController, setClientEventMetadataPopulator, ModalButtonType, ModalSize, ModalType, Variant, IntelliTableColumn, DropdownItemType, LogReviewerFilterState, ProgressBarSize, BackState, BackButtonController, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, 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, SELECT_ADMIN_CHECK_ROUTE, abbreviate, avg, ceilToNumDecimals, convertDateKeyToDateInfo, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, getMondayOfTimestamp, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, extractProp, compareArraysByProp, getLocalTimeInfo, genCommaList, validateEmail, validatePhoneNumber, validateString, idify, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, cloneDeep, getTimestampFromTimeInfoInET, spaceAtCapitals, ParamType, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, LogTypeSpecificInfo, LogMainInfo, LogSourceSpecificInfo, LogLevel, CommonKitErrorCode, };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { LogMetadataType, ParamType, LogFunction } from 'dce-commonkit';
|
|
3
|
-
export { CommonKitErrorCode, DAY_IN_MS, DayOfWeek, ErrorWithCode, HOUR_IN_MS, LOG_REVIEW_GET_LOGS_ROUTE, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, Log, LogAction, LogBuiltInMetadata, LogFunction, LogLevel, LogMainInfo, LogMetadataType, LogReviewerFilterState, LogSource, LogSourceSpecificInfo, LogType, LogTypeSpecificInfo, MINUTE_IN_MS, ParamType, SELECT_ADMIN_CHECK_ROUTE, abbreviate, avg, capitalize, ceilToNumDecimals, cloneDeep, compareArraysByProp, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, getHumanReadableDate, getLocalTimeInfo, getMondayOfTimestamp, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, getTimestampFromTimeInfoInET, getWordCount, idify, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, roundToNumDecimals, shuffleArray, someAsync, spaceAtCapitals, startMinWait, stringsToHumanReadableList, sum, validateEmail, validatePhoneNumber, validateString, waitMs } from 'dce-commonkit';
|
|
3
|
+
export { CommonKitErrorCode, DAY_IN_MS, DayOfWeek, ErrorWithCode, HOUR_IN_MS, LOG_REVIEW_GET_LOGS_ROUTE, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, Log, LogAction, LogBuiltInMetadata, LogFunction, LogLevel, LogMainInfo, LogMetadataType, LogReviewerFilterState, LogSource, LogSourceSpecificInfo, LogType, LogTypeSpecificInfo, MINUTE_IN_MS, ParamType, SELECT_ADMIN_CHECK_ROUTE, abbreviate, avg, capitalize, ceilToNumDecimals, cloneDeep, compareArraysByProp, convertDateKeyToDateInfo, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, getHumanReadableDate, getLocalTimeInfo, getMondayOfTimestamp, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, getTimestampFromTimeInfoInET, getWordCount, idify, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, roundToNumDecimals, shuffleArray, someAsync, spaceAtCapitals, startMinWait, stringsToHumanReadableList, sum, validateEmail, validatePhoneNumber, validateString, waitMs } from 'dce-commonkit';
|
|
4
4
|
import React$1 from 'react';
|
|
5
5
|
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dce-reactkit",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.11",
|
|
4
4
|
"description": "Shared components for Harvard DCE apps",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://github.com/harvard-edtech/dce-reactkit#readme",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"dce-commonkit": "^5.0.
|
|
27
|
+
"dce-commonkit": "^5.0.3",
|
|
28
28
|
"react-select": "^5.7.3"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
3
|
|
|
4
4
|
// Import components
|
|
5
|
-
import { alert, confirm } from '../components/AppWrapper';
|
|
5
|
+
import { alert, confirm, addFatalErrorHandler } from '../components/AppWrapper';
|
|
6
6
|
|
|
7
7
|
// Import types
|
|
8
8
|
import BackState from '../types/BackState';
|
|
@@ -54,6 +54,9 @@ type BackButtonState = {
|
|
|
54
54
|
// True if the next back navigation was triggered by us and must pass through
|
|
55
55
|
// without being intercepted
|
|
56
56
|
bypassNextPop: boolean,
|
|
57
|
+
// True once a fatal error has replaced the app. Back navigation is never
|
|
58
|
+
// intercepted after this: there is no app left to keep the user inside of
|
|
59
|
+
fatalErrorShown: boolean,
|
|
57
60
|
};
|
|
58
61
|
|
|
59
62
|
/*------------------------------------------------------------------------*/
|
|
@@ -65,6 +68,7 @@ type BackButtonState = {
|
|
|
65
68
|
let state: BackButtonState = {
|
|
66
69
|
promptVisible: false,
|
|
67
70
|
bypassNextPop: false,
|
|
71
|
+
fatalErrorShown: false,
|
|
68
72
|
};
|
|
69
73
|
|
|
70
74
|
/*------------------------------------------------------------------------*/
|
|
@@ -166,6 +170,12 @@ const handlePopState = () => {
|
|
|
166
170
|
return;
|
|
167
171
|
}
|
|
168
172
|
|
|
173
|
+
// A fatal error replaced the app: there is nothing left to go back to within
|
|
174
|
+
// it, so let the browser leave instead of trapping the user on the error
|
|
175
|
+
if (state.fatalErrorShown) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
169
179
|
// Already on the home screen: nothing for us to intercept
|
|
170
180
|
if (!state.subpanel) {
|
|
171
181
|
return;
|
|
@@ -334,6 +344,14 @@ const useBackButton = (handleGoHomeFunc: () => void) => {
|
|
|
334
344
|
// Mark the current entry as the home entry
|
|
335
345
|
window.history.replaceState(HISTORY_STATE_MARKER, '');
|
|
336
346
|
|
|
347
|
+
// A fatal error (or an expired session) ends the app: drop the subpanel
|
|
348
|
+
// so no task is left looking like it's still in progress, and stop
|
|
349
|
+
// intercepting back navigation altogether
|
|
350
|
+
addFatalErrorHandler(() => {
|
|
351
|
+
state.subpanel = undefined;
|
|
352
|
+
state.fatalErrorShown = true;
|
|
353
|
+
});
|
|
354
|
+
|
|
337
355
|
window.addEventListener('popstate', handlePopState);
|
|
338
356
|
return () => {
|
|
339
357
|
window.removeEventListener('popstate', handlePopState);
|
|
@@ -342,6 +360,7 @@ const useBackButton = (handleGoHomeFunc: () => void) => {
|
|
|
342
360
|
state = {
|
|
343
361
|
promptVisible: false,
|
|
344
362
|
bypassNextPop: false,
|
|
363
|
+
fatalErrorShown: false,
|
|
345
364
|
};
|
|
346
365
|
};
|
|
347
366
|
},
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
abbreviate,
|
|
16
16
|
avg,
|
|
17
17
|
ceilToNumDecimals,
|
|
18
|
+
convertDateKeyToDateInfo,
|
|
18
19
|
floorToNumDecimals,
|
|
19
20
|
forceNumIntoBounds,
|
|
20
21
|
padDecimalZeros,
|
|
@@ -228,6 +229,7 @@ export {
|
|
|
228
229
|
abbreviate,
|
|
229
230
|
avg,
|
|
230
231
|
ceilToNumDecimals,
|
|
232
|
+
convertDateKeyToDateInfo,
|
|
231
233
|
floorToNumDecimals,
|
|
232
234
|
forceNumIntoBounds,
|
|
233
235
|
padDecimalZeros,
|