dce-reactkit 3.5.11 → 3.5.12
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 +84 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/AppWrapper.d.ts +8 -0
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/esm/index.js +84 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/AppWrapper.d.ts +8 -0
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/index.d.ts +9 -1
- package/package.json +1 -1
- package/src/components/AppWrapper.tsx +116 -1
- package/src/index.ts +2 -0
|
@@ -9,6 +9,14 @@ type Props = {
|
|
|
9
9
|
children: React.ReactNode;
|
|
10
10
|
dark?: boolean;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Redirect to a new page
|
|
14
|
+
* @author Gabe Abrams
|
|
15
|
+
* @param url the url to redirect to
|
|
16
|
+
* @param destination the destination of the redirect, for example "YouTube"
|
|
17
|
+
* and will be used in the following text: `Redirecting to ${destination}...`
|
|
18
|
+
*/
|
|
19
|
+
export declare const leaveToURL: (url: string, destination: string) => Promise<void>;
|
|
12
20
|
/**
|
|
13
21
|
* Show an alert modal with an "Okay" button
|
|
14
22
|
* @author Gabe Abrams
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import AppWrapper, { alert, confirm, showFatalError, addFatalErrorHandler } from './components/AppWrapper';
|
|
1
|
+
import AppWrapper, { alert, confirm, showFatalError, addFatalErrorHandler, leaveToURL } from './components/AppWrapper';
|
|
2
2
|
import LoadingSpinner from './components/LoadingSpinner';
|
|
3
3
|
import ErrorBox from './components/ErrorBox';
|
|
4
4
|
import Modal from './components/Modal';
|
|
@@ -83,4 +83,4 @@ import PickableItem from './components/ItemPicker/types/PickableItem';
|
|
|
83
83
|
import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
|
|
84
84
|
import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
|
|
85
85
|
import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
|
|
86
|
-
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, 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, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
|
|
86
|
+
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, 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, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
|
package/dist/esm/index.js
CHANGED
|
@@ -293,7 +293,7 @@ const ModalButtonTypeToLabelAndVariant = {
|
|
|
293
293
|
/*------------------------------------------------------------------------*/
|
|
294
294
|
/* Style */
|
|
295
295
|
/*------------------------------------------------------------------------*/
|
|
296
|
-
const style$
|
|
296
|
+
const style$b = `
|
|
297
297
|
.Modal-backdrop {
|
|
298
298
|
position: fixed;
|
|
299
299
|
top: 0;
|
|
@@ -467,7 +467,7 @@ const Modal = (props) => {
|
|
|
467
467
|
left: 0,
|
|
468
468
|
right: 0,
|
|
469
469
|
} },
|
|
470
|
-
React__default.createElement("style", null, style$
|
|
470
|
+
React__default.createElement("style", null, style$b),
|
|
471
471
|
React__default.createElement("div", { className: `Modal-backdrop ${backdropAnimationClass}`, style: {
|
|
472
472
|
zIndex: 5000000003,
|
|
473
473
|
}, onClick: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -755,6 +755,39 @@ const logClientEvent = (opts) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
755
755
|
/* --------------------------- Static Helpers --------------------------- */
|
|
756
756
|
/*------------------------------------------------------------------------*/
|
|
757
757
|
/*----------------------------------------*/
|
|
758
|
+
/* ----------- Redirect/Leave ----------- */
|
|
759
|
+
/*----------------------------------------*/
|
|
760
|
+
// Stored copy of setter for url to leave to
|
|
761
|
+
let setURLToLeaveTo;
|
|
762
|
+
/**
|
|
763
|
+
* Redirect to a new page
|
|
764
|
+
* @author Gabe Abrams
|
|
765
|
+
* @param url the url to redirect to
|
|
766
|
+
* @param destination the destination of the redirect, for example "YouTube"
|
|
767
|
+
* and will be used in the following text: `Redirecting to ${destination}...`
|
|
768
|
+
*/
|
|
769
|
+
const leaveToURL = (url, destination) => __awaiter(void 0, void 0, void 0, function* () {
|
|
770
|
+
if (setURLToLeaveTo) {
|
|
771
|
+
// Beautiful redirect
|
|
772
|
+
setURLToLeaveTo({ url, destination });
|
|
773
|
+
}
|
|
774
|
+
else {
|
|
775
|
+
// Overwrite page in a janky way
|
|
776
|
+
window.document.body.innerHTML = `
|
|
777
|
+
<div>
|
|
778
|
+
<h1>
|
|
779
|
+
Redirecting to ${destination}...
|
|
780
|
+
</h1>
|
|
781
|
+
<p>
|
|
782
|
+
If you are not redirected in 5 seconds, please <a href="${url}">click here</a>.
|
|
783
|
+
</p>
|
|
784
|
+
</div>
|
|
785
|
+
`;
|
|
786
|
+
}
|
|
787
|
+
// Redirect to location
|
|
788
|
+
window.location.href = url;
|
|
789
|
+
});
|
|
790
|
+
/*----------------------------------------*/
|
|
758
791
|
/* ---------------- Alert --------------- */
|
|
759
792
|
/*----------------------------------------*/
|
|
760
793
|
// Stored copies of setters
|
|
@@ -891,6 +924,30 @@ const addFatalErrorHandler = (handler) => {
|
|
|
891
924
|
fatalErrorHandlers.push(handler);
|
|
892
925
|
};
|
|
893
926
|
/*------------------------------------------------------------------------*/
|
|
927
|
+
/* -------------------------------- Style ------------------------------- */
|
|
928
|
+
/*------------------------------------------------------------------------*/
|
|
929
|
+
const style$a = `
|
|
930
|
+
.AppWrapper-leave-to-url-notice {
|
|
931
|
+
opacity: 0;
|
|
932
|
+
|
|
933
|
+
animation-name: AppWrapper-leave-to-url-notice-appear;
|
|
934
|
+
animation-duration: 0.5s;
|
|
935
|
+
animation-delay: 1s;
|
|
936
|
+
animation-fill-mode: both;
|
|
937
|
+
animation-timing-function: ease-out;
|
|
938
|
+
animation-iteration-count: 1;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
@keyframes AppWrapper-leave-to-url-notice-appear {
|
|
942
|
+
0% {
|
|
943
|
+
opacity: 0;
|
|
944
|
+
}
|
|
945
|
+
100% {
|
|
946
|
+
opacity: 1;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
`;
|
|
950
|
+
/*------------------------------------------------------------------------*/
|
|
894
951
|
/* ------------------------------ Component ----------------------------- */
|
|
895
952
|
/*------------------------------------------------------------------------*/
|
|
896
953
|
const AppWrapper = (props) => {
|
|
@@ -900,6 +957,9 @@ const AppWrapper = (props) => {
|
|
|
900
957
|
/* -------------- Props ------------- */
|
|
901
958
|
const { children, dark, } = props;
|
|
902
959
|
/* -------------- State ------------- */
|
|
960
|
+
// Leave to URL
|
|
961
|
+
const [urlToLeaveTo, setURLToLeaveToInner,] = useState();
|
|
962
|
+
setURLToLeaveTo = setURLToLeaveToInner;
|
|
903
963
|
// Fatal error
|
|
904
964
|
const [fatalErrorMessage, setFatalErrorMessageInner,] = useState();
|
|
905
965
|
setFatalErrorMessage = setFatalErrorMessageInner;
|
|
@@ -947,8 +1007,27 @@ const AppWrapper = (props) => {
|
|
|
947
1007
|
/*----------------------------------------*/
|
|
948
1008
|
// Body that will be filled with the current view
|
|
949
1009
|
let body;
|
|
1010
|
+
/* ---------- Leave to URL ---------- */
|
|
1011
|
+
if (!body && urlToLeaveTo) {
|
|
1012
|
+
// Destructure url info
|
|
1013
|
+
const { url, destination, } = urlToLeaveTo;
|
|
1014
|
+
// Show pretty redirect screen
|
|
1015
|
+
body = (React__default.createElement("div", { className: "AppWrapper-leave-to-url-container p-5 text-center" },
|
|
1016
|
+
React__default.createElement("div", { className: "AppWrapper-leave-to-url-notice d-inline-block" },
|
|
1017
|
+
React__default.createElement("h3", { className: "text-start m-0" },
|
|
1018
|
+
"Redirecting to",
|
|
1019
|
+
' ',
|
|
1020
|
+
destination,
|
|
1021
|
+
"..."),
|
|
1022
|
+
React__default.createElement("div", { className: "text-start" },
|
|
1023
|
+
"If you are not automatically redirected in 5 seconds, please",
|
|
1024
|
+
' ',
|
|
1025
|
+
React__default.createElement("a", { href: url, "aria-label": `Click here to leave to ${destination}` }, "click here"),
|
|
1026
|
+
"."))));
|
|
1027
|
+
}
|
|
950
1028
|
/* ----------- Fatal Error ---------- */
|
|
951
|
-
if (
|
|
1029
|
+
if (!body
|
|
1030
|
+
&& (fatalErrorMessage || fatalErrorCode || sessionHasExpired)) {
|
|
952
1031
|
// Re-encapsulate in an error
|
|
953
1032
|
const error = (sessionHasExpired
|
|
954
1033
|
? new ErrorWithCode(getSessionExpiredMessage(), ReactKitErrorCode$1.SessionExpired)
|
|
@@ -975,6 +1054,7 @@ const AppWrapper = (props) => {
|
|
|
975
1054
|
/* Main UI */
|
|
976
1055
|
/*----------------------------------------*/
|
|
977
1056
|
return (React__default.createElement(React__default.Fragment, null,
|
|
1057
|
+
React__default.createElement("style", null, style$a),
|
|
978
1058
|
modal,
|
|
979
1059
|
body));
|
|
980
1060
|
};
|
|
@@ -42842,5 +42922,5 @@ var DayOfWeek;
|
|
|
42842
42922
|
})(DayOfWeek || (DayOfWeek = {}));
|
|
42843
42923
|
var DayOfWeek$1 = DayOfWeek;
|
|
42844
42924
|
|
|
42845
|
-
export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, 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, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert$1 as alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
|
|
42925
|
+
export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, 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, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert$1 as alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
|
|
42846
42926
|
//# sourceMappingURL=index.js.map
|