dce-reactkit 3.5.10 → 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 +103 -19
- 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 +103 -20
- 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/components/AutoscrollToBottomContainer.tsx +24 -18
- 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
|
};
|
|
@@ -40825,7 +40905,7 @@ const AutoscrollToBottomContainer = (props) => {
|
|
|
40825
40905
|
// Initialize refs
|
|
40826
40906
|
const lastItemIds = useRef([]);
|
|
40827
40907
|
const container = useRef(null);
|
|
40828
|
-
const
|
|
40908
|
+
const wasLastScrolledToBottom = useRef(true);
|
|
40829
40909
|
/*------------------------------------------------------------------------*/
|
|
40830
40910
|
/* ------------------------- Component Functions ------------------------ */
|
|
40831
40911
|
/*------------------------------------------------------------------------*/
|
|
@@ -40848,7 +40928,10 @@ const AutoscrollToBottomContainer = (props) => {
|
|
|
40848
40928
|
const rootFontSizePx = Number.parseInt(getComputedStyle(document.documentElement).fontSize, 10);
|
|
40849
40929
|
const distanceToBottomRems = Math.abs((scrollTop + clientHeight - scrollHeight) / rootFontSizePx);
|
|
40850
40930
|
// Figure out if we're scrolled to the bottom
|
|
40851
|
-
|
|
40931
|
+
const atBottom = (distanceToBottomRems < SCROLLED_TO_BOTTOM_THRESHOLD_REMS);
|
|
40932
|
+
// Remember if we scrolled to the bottom
|
|
40933
|
+
wasLastScrolledToBottom.current = atBottom;
|
|
40934
|
+
return atBottom;
|
|
40852
40935
|
};
|
|
40853
40936
|
/**
|
|
40854
40937
|
* Scroll the user to the bottom of the container
|
|
@@ -40864,7 +40947,10 @@ const AutoscrollToBottomContainer = (props) => {
|
|
|
40864
40947
|
type: ActionType.HideJumpToBottomButton,
|
|
40865
40948
|
});
|
|
40866
40949
|
// Scroll to bottom
|
|
40867
|
-
container.current.scrollTop = container.current.scrollHeight
|
|
40950
|
+
container.current.scrollTop = (container.current.scrollHeight
|
|
40951
|
+
- container.current.clientHeight);
|
|
40952
|
+
// Remember that we scrolled to the bottom
|
|
40953
|
+
wasLastScrolledToBottom.current = true;
|
|
40868
40954
|
};
|
|
40869
40955
|
/*----------------------------------------*/
|
|
40870
40956
|
/* -------------- Handlers -------------- */
|
|
@@ -40878,8 +40964,9 @@ const AutoscrollToBottomContainer = (props) => {
|
|
|
40878
40964
|
if (!container.current) {
|
|
40879
40965
|
return;
|
|
40880
40966
|
}
|
|
40881
|
-
// If scrolled to bottom, hide the button
|
|
40967
|
+
// If scrolled to bottom, hide the button and remember position
|
|
40882
40968
|
if (isScrolledToBottom()) {
|
|
40969
|
+
// Hide button
|
|
40883
40970
|
dispatch({
|
|
40884
40971
|
type: ActionType.HideJumpToBottomButton,
|
|
40885
40972
|
});
|
|
@@ -40904,17 +40991,19 @@ const AutoscrollToBottomContainer = (props) => {
|
|
|
40904
40991
|
// Check if new content appeared
|
|
40905
40992
|
const currentItemIds = getItemIds(items);
|
|
40906
40993
|
// Check if new content appeared at bottom
|
|
40907
|
-
const newContentAppeared = (
|
|
40908
|
-
|
|
40909
|
-
|
|
40910
|
-
|
|
40911
|
-
|
|
40994
|
+
const newContentAppeared = (
|
|
40995
|
+
// There are items
|
|
40996
|
+
currentItemIds.length > 0
|
|
40997
|
+
// The last item is new
|
|
40998
|
+
&& !lastItemIds.current.includes(currentItemIds[currentItemIds.length - 1]));
|
|
40999
|
+
// Update last item ids
|
|
41000
|
+
lastItemIds.current = currentItemIds;
|
|
40912
41001
|
// Do nothing if no new content
|
|
40913
41002
|
if (!newContentAppeared) {
|
|
40914
41003
|
return;
|
|
40915
41004
|
}
|
|
40916
41005
|
// Check if used to be scrolled to the bottom
|
|
40917
|
-
if (
|
|
41006
|
+
if (wasLastScrolledToBottom.current) {
|
|
40918
41007
|
// Was scrolled to the bottom! Autoscroll.
|
|
40919
41008
|
scrollToBottom();
|
|
40920
41009
|
}
|
|
@@ -40924,12 +41013,6 @@ const AutoscrollToBottomContainer = (props) => {
|
|
|
40924
41013
|
type: ActionType.ShowJumpToBottomButton,
|
|
40925
41014
|
});
|
|
40926
41015
|
}
|
|
40927
|
-
// Update last item ids
|
|
40928
|
-
lastItemIds.current = currentItemIds;
|
|
40929
|
-
// Remember if we were scrolled to the bottom before the update
|
|
40930
|
-
return () => {
|
|
40931
|
-
wasScrolledToBottomBeforeItemsUpdate.current = isScrolledToBottom();
|
|
40932
|
-
};
|
|
40933
41016
|
}, [items]);
|
|
40934
41017
|
/*------------------------------------------------------------------------*/
|
|
40935
41018
|
/* ------------------------------- Render ------------------------------- */
|
|
@@ -42839,5 +42922,5 @@ var DayOfWeek;
|
|
|
42839
42922
|
})(DayOfWeek || (DayOfWeek = {}));
|
|
42840
42923
|
var DayOfWeek$1 = DayOfWeek;
|
|
42841
42924
|
|
|
42842
|
-
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 };
|
|
42843
42926
|
//# sourceMappingURL=index.js.map
|