dce-reactkit 3.5.6 → 3.5.8
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 +24 -44
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/{ScrollLockToBottomContainer.d.ts → AutoscrollToBottomContainer.d.ts} +5 -3
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/esm/index.js +24 -44
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/{ScrollLockToBottomContainer.d.ts → AutoscrollToBottomContainer.d.ts} +5 -3
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/index.d.ts +5 -3
- package/package.json +1 -1
- package/src/components/{ScrollLockToBottomContainer.tsx → AutoscrollToBottomContainer.tsx} +24 -48
- package/src/index.ts +2 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Container that automatically scrolls when new items are added,
|
|
3
3
|
* lets the user scroll up to see old items, but resumes
|
|
4
|
-
* autoscroll when the user scrolls back to the bottom
|
|
4
|
+
* autoscroll when the user scrolls back to the bottom.
|
|
5
|
+
* Note: takes up full height of parent, so parent should
|
|
6
|
+
* have a determined height for the scroll to work.
|
|
5
7
|
* @author Gabe Abrams
|
|
6
8
|
*/
|
|
7
9
|
import React from 'react';
|
|
@@ -15,5 +17,5 @@ type AutoScrollItem = {
|
|
|
15
17
|
id: string | number;
|
|
16
18
|
item: React.ReactNode;
|
|
17
19
|
};
|
|
18
|
-
declare const
|
|
19
|
-
export default
|
|
20
|
+
declare const AutoscrollToBottomContainer: React.FC<Props>;
|
|
21
|
+
export default AutoscrollToBottomContainer;
|
|
@@ -19,7 +19,7 @@ import CSVDownloadButton from './components/CSVDownloadButton';
|
|
|
19
19
|
import DBEntryManagerPanel from './components/DBEntryManagerPanel';
|
|
20
20
|
import Tooltip from './components/Tooltip';
|
|
21
21
|
import ToggleSwitch from './components/ToggleSwitch';
|
|
22
|
-
import
|
|
22
|
+
import AutoscrollToBottomContainer from './components/AutoscrollToBottomContainer';
|
|
23
23
|
import ErrorWithCode from './errors/ErrorWithCode';
|
|
24
24
|
import MINUTE_IN_MS from './constants/MINUTE_IN_MS';
|
|
25
25
|
import HOUR_IN_MS from './constants/HOUR_IN_MS';
|
|
@@ -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,
|
|
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, };
|
package/dist/esm/index.js
CHANGED
|
@@ -40707,35 +40707,31 @@ const idify = (str) => {
|
|
|
40707
40707
|
/**
|
|
40708
40708
|
* Container that automatically scrolls when new items are added,
|
|
40709
40709
|
* lets the user scroll up to see old items, but resumes
|
|
40710
|
-
* autoscroll when the user scrolls back to the bottom
|
|
40710
|
+
* autoscroll when the user scrolls back to the bottom.
|
|
40711
|
+
* Note: takes up full height of parent, so parent should
|
|
40712
|
+
* have a determined height for the scroll to work.
|
|
40711
40713
|
* @author Gabe Abrams
|
|
40712
40714
|
*/
|
|
40713
40715
|
/*------------------------------------------------------------------------*/
|
|
40714
40716
|
/* -------------------------------- Style ------------------------------- */
|
|
40715
40717
|
/*------------------------------------------------------------------------*/
|
|
40716
40718
|
const style = `
|
|
40717
|
-
.
|
|
40719
|
+
.AutoscrollToBottomContainer-outer-container {
|
|
40718
40720
|
/* Take up all space */
|
|
40719
40721
|
height: 100%;
|
|
40720
40722
|
position: relative;
|
|
40721
40723
|
}
|
|
40722
40724
|
|
|
40723
|
-
.
|
|
40725
|
+
.AutoscrollToBottomContainer-scrollable-container {
|
|
40724
40726
|
/* Take up max 100% height, don't take it up if not needed */
|
|
40725
|
-
/* (so column-reverse layout doesn't start at the bottom) */
|
|
40726
40727
|
max-height: 100%;
|
|
40727
40728
|
overflow-y: auto;
|
|
40728
40729
|
|
|
40729
40730
|
/* Allow children to position */
|
|
40730
40731
|
position: relative;
|
|
40731
|
-
|
|
40732
|
-
/* Reverse order of children so scroll starts at bottom */
|
|
40733
|
-
/* (but children will have to be rendered in reverse order) */
|
|
40734
|
-
display: flex;
|
|
40735
|
-
flex-direction: column-reverse;
|
|
40736
40732
|
}
|
|
40737
40733
|
|
|
40738
|
-
.
|
|
40734
|
+
.AutoscrollToBottomContainer-jump-to-bottom-container {
|
|
40739
40735
|
/* Don't take any space in parent */
|
|
40740
40736
|
height: 0;
|
|
40741
40737
|
overflow: visible;
|
|
@@ -40752,7 +40748,7 @@ const style = `
|
|
|
40752
40748
|
text-align: center;
|
|
40753
40749
|
}
|
|
40754
40750
|
|
|
40755
|
-
.
|
|
40751
|
+
.AutoscrollToBottomContainer-item-container {
|
|
40756
40752
|
/* Normal Height */
|
|
40757
40753
|
position: relative;
|
|
40758
40754
|
z-index: 1;
|
|
@@ -40763,7 +40759,7 @@ const style = `
|
|
|
40763
40759
|
/*------------------------------------------------------------------------*/
|
|
40764
40760
|
// Scrolled to bottom threshold
|
|
40765
40761
|
// (how close you have to be to the bottom for it to count as the bottom)
|
|
40766
|
-
const SCROLLED_TO_BOTTOM_THRESHOLD_REMS =
|
|
40762
|
+
const SCROLLED_TO_BOTTOM_THRESHOLD_REMS = 1.5;
|
|
40767
40763
|
/*------------------------------------------------------------------------*/
|
|
40768
40764
|
/* -------------------------- Static Functions -------------------------- */
|
|
40769
40765
|
/*------------------------------------------------------------------------*/
|
|
@@ -40784,8 +40780,6 @@ var ActionType;
|
|
|
40784
40780
|
(function (ActionType) {
|
|
40785
40781
|
// Identify that the user is now scrolled to the bottom
|
|
40786
40782
|
ActionType["NowScrolledToBottom"] = "NowScrolledToBottom";
|
|
40787
|
-
// Identify that the user scrolled away from the bottom
|
|
40788
|
-
ActionType["NowScrolledAwayFromBottom"] = "NowScrolledAwayFromBottom";
|
|
40789
40783
|
// Identify that new content appeared at the bottom but is not visible
|
|
40790
40784
|
ActionType["NewContentAtBottom"] = "NewContentAtBottom";
|
|
40791
40785
|
})(ActionType || (ActionType = {}));
|
|
@@ -40799,20 +40793,11 @@ const reducer = (state, action) => {
|
|
|
40799
40793
|
switch (action.type) {
|
|
40800
40794
|
case ActionType.NowScrolledToBottom: {
|
|
40801
40795
|
return Object.assign(Object.assign({}, state), {
|
|
40802
|
-
// Store the event
|
|
40803
|
-
wasScrolledToBottom: true,
|
|
40804
40796
|
// Hide the "jump to bottom" button
|
|
40805
40797
|
jumpToBottomButtonVisible: false });
|
|
40806
40798
|
}
|
|
40807
|
-
case ActionType.NowScrolledAwayFromBottom: {
|
|
40808
|
-
return Object.assign(Object.assign({}, state), {
|
|
40809
|
-
// Store the event
|
|
40810
|
-
wasScrolledToBottom: false });
|
|
40811
|
-
}
|
|
40812
40799
|
case ActionType.NewContentAtBottom: {
|
|
40813
40800
|
return Object.assign(Object.assign({}, state), {
|
|
40814
|
-
// Store the event
|
|
40815
|
-
wasScrolledToBottom: false,
|
|
40816
40801
|
// Show the "jump to bottom" button
|
|
40817
40802
|
jumpToBottomButtonVisible: true });
|
|
40818
40803
|
}
|
|
@@ -40824,7 +40809,7 @@ const reducer = (state, action) => {
|
|
|
40824
40809
|
/*------------------------------------------------------------------------*/
|
|
40825
40810
|
/* ------------------------------ Component ----------------------------- */
|
|
40826
40811
|
/*------------------------------------------------------------------------*/
|
|
40827
|
-
const
|
|
40812
|
+
const AutoscrollToBottomContainer = (props) => {
|
|
40828
40813
|
/*------------------------------------------------------------------------*/
|
|
40829
40814
|
/* -------------------------------- Setup ------------------------------- */
|
|
40830
40815
|
/*------------------------------------------------------------------------*/
|
|
@@ -40834,17 +40819,17 @@ const ScrollLockToBottom = (props) => {
|
|
|
40834
40819
|
/* -------------- State ------------- */
|
|
40835
40820
|
// Initial state
|
|
40836
40821
|
const initialState = {
|
|
40837
|
-
wasScrolledToBottom: true,
|
|
40838
40822
|
jumpToBottomButtonVisible: false,
|
|
40839
40823
|
};
|
|
40840
40824
|
// Initialize state
|
|
40841
40825
|
const [state, dispatch] = useReducer(reducer, initialState);
|
|
40842
40826
|
// Destructure common state
|
|
40843
|
-
const {
|
|
40827
|
+
const { jumpToBottomButtonVisible, } = state;
|
|
40844
40828
|
/* -------------- Refs -------------- */
|
|
40845
40829
|
// Initialize refs
|
|
40846
40830
|
const lastItemIds = useRef([]);
|
|
40847
40831
|
const container = useRef(null);
|
|
40832
|
+
const wasScrolledToBottomBeforeItemsUpdate = useRef(true);
|
|
40848
40833
|
/*------------------------------------------------------------------------*/
|
|
40849
40834
|
/* ------------------------- Component Functions ------------------------ */
|
|
40850
40835
|
/*------------------------------------------------------------------------*/
|
|
@@ -40905,11 +40890,6 @@ const ScrollLockToBottom = (props) => {
|
|
|
40905
40890
|
type: ActionType.NowScrolledToBottom,
|
|
40906
40891
|
});
|
|
40907
40892
|
}
|
|
40908
|
-
else {
|
|
40909
|
-
dispatch({
|
|
40910
|
-
type: ActionType.NowScrolledAwayFromBottom,
|
|
40911
|
-
});
|
|
40912
|
-
}
|
|
40913
40893
|
};
|
|
40914
40894
|
/*------------------------------------------------------------------------*/
|
|
40915
40895
|
/* ------------------------- Lifecycle Functions ------------------------ */
|
|
@@ -40923,7 +40903,7 @@ const ScrollLockToBottom = (props) => {
|
|
|
40923
40903
|
scrollToBottom();
|
|
40924
40904
|
}, []);
|
|
40925
40905
|
/**
|
|
40926
|
-
* Update (also called on mount)
|
|
40906
|
+
* Update (also called on mount): autoscroll
|
|
40927
40907
|
* @author Gabe Abrams
|
|
40928
40908
|
*/
|
|
40929
40909
|
useEffect(() => {
|
|
@@ -40938,7 +40918,7 @@ const ScrollLockToBottom = (props) => {
|
|
|
40938
40918
|
return;
|
|
40939
40919
|
}
|
|
40940
40920
|
// Check if used to be scrolled to the bottom
|
|
40941
|
-
if (
|
|
40921
|
+
if (wasScrolledToBottomBeforeItemsUpdate.current) {
|
|
40942
40922
|
// Was scrolled to the bottom! Autoscroll.
|
|
40943
40923
|
scrollToBottom();
|
|
40944
40924
|
}
|
|
@@ -40950,6 +40930,10 @@ const ScrollLockToBottom = (props) => {
|
|
|
40950
40930
|
}
|
|
40951
40931
|
// Update last item ids
|
|
40952
40932
|
lastItemIds.current = currentItemIds;
|
|
40933
|
+
// Remember if we were scrolled to the bottom before the update
|
|
40934
|
+
return () => {
|
|
40935
|
+
wasScrolledToBottomBeforeItemsUpdate.current = isScrolledToBottom();
|
|
40936
|
+
};
|
|
40953
40937
|
}, [items]);
|
|
40954
40938
|
/*------------------------------------------------------------------------*/
|
|
40955
40939
|
/* ------------------------------- Render ------------------------------- */
|
|
@@ -40960,25 +40944,21 @@ const ScrollLockToBottom = (props) => {
|
|
|
40960
40944
|
// Jump to Bottom button
|
|
40961
40945
|
let jumpToBottomButton;
|
|
40962
40946
|
if (jumpToBottomButtonVisible) {
|
|
40963
|
-
jumpToBottomButton = (React__default.createElement("div", { className: `
|
|
40964
|
-
React__default.createElement("button", { type: "button", className: `
|
|
40947
|
+
jumpToBottomButton = (React__default.createElement("div", { className: `AutoscrollToBottomContainer-jump-to-bottom-container AutoscrollToBottomContainer-for-${idify(itemsName !== null && itemsName !== void 0 ? itemsName : 'items')}` },
|
|
40948
|
+
React__default.createElement("button", { type: "button", className: `AutoscrollToBottomContainer-jump-to-bottom-button AutoscrollToBottomContainer-jump-to-bottom-button-for-${idify(itemsName !== null && itemsName !== void 0 ? itemsName : 'items')} btn btn-sm btn-${jumpToBottomButtonVariant} pt-0 pb-0`, onClick: scrollToBottom, "aria-label": "scroll back to bottom and show new content" },
|
|
40965
40949
|
"New",
|
|
40966
40950
|
' ', itemsName !== null && itemsName !== void 0 ? itemsName : 'Content',
|
|
40967
40951
|
React__default.createElement(FontAwesomeIcon, { icon: faChevronDown, className: "ms-1" }))));
|
|
40968
40952
|
}
|
|
40969
40953
|
// Main UI
|
|
40970
|
-
return (React__default.createElement("div", { className: "
|
|
40954
|
+
return (React__default.createElement("div", { className: "AutoscrollToBottomContainer-outer-container" },
|
|
40971
40955
|
React__default.createElement("style", null, style),
|
|
40972
40956
|
jumpToBottomButton,
|
|
40973
|
-
React__default.createElement("div", { className: "
|
|
40974
|
-
handleScroll();
|
|
40975
|
-
}, ref: container }, items
|
|
40957
|
+
React__default.createElement("div", { className: "AutoscrollToBottomContainer-scrollable-container", onScroll: handleScroll, ref: container }, items
|
|
40976
40958
|
// Render each item with a key
|
|
40977
40959
|
.map((item) => {
|
|
40978
|
-
return (React__default.createElement("div", { className: "
|
|
40979
|
-
})
|
|
40980
|
-
// Reverse order because flex column is reverse
|
|
40981
|
-
.reverse())));
|
|
40960
|
+
return (React__default.createElement("div", { className: "AutoscrollToBottomContainer-item-container", key: item.id }, item.item));
|
|
40961
|
+
}))));
|
|
40982
40962
|
};
|
|
40983
40963
|
|
|
40984
40964
|
/**
|
|
@@ -42860,5 +42840,5 @@ var DayOfWeek;
|
|
|
42860
42840
|
})(DayOfWeek || (DayOfWeek = {}));
|
|
42861
42841
|
var DayOfWeek$1 = DayOfWeek;
|
|
42862
42842
|
|
|
42863
|
-
export { AppWrapper, 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,
|
|
42843
|
+
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 };
|
|
42864
42844
|
//# sourceMappingURL=index.js.map
|