dce-reactkit 3.5.7 → 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 +11 -33
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +11 -33
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AutoscrollToBottomContainer.tsx +10 -36
package/dist/cjs/index.js
CHANGED
|
@@ -40750,17 +40750,11 @@ const style = `
|
|
|
40750
40750
|
|
|
40751
40751
|
.AutoscrollToBottomContainer-scrollable-container {
|
|
40752
40752
|
/* Take up max 100% height, don't take it up if not needed */
|
|
40753
|
-
/* (so column-reverse layout doesn't start at the bottom) */
|
|
40754
40753
|
max-height: 100%;
|
|
40755
40754
|
overflow-y: auto;
|
|
40756
40755
|
|
|
40757
40756
|
/* Allow children to position */
|
|
40758
40757
|
position: relative;
|
|
40759
|
-
|
|
40760
|
-
/* Reverse order of children so scroll starts at bottom */
|
|
40761
|
-
/* (but children will have to be rendered in reverse order) */
|
|
40762
|
-
display: flex;
|
|
40763
|
-
flex-direction: column-reverse;
|
|
40764
40758
|
}
|
|
40765
40759
|
|
|
40766
40760
|
.AutoscrollToBottomContainer-jump-to-bottom-container {
|
|
@@ -40791,7 +40785,7 @@ const style = `
|
|
|
40791
40785
|
/*------------------------------------------------------------------------*/
|
|
40792
40786
|
// Scrolled to bottom threshold
|
|
40793
40787
|
// (how close you have to be to the bottom for it to count as the bottom)
|
|
40794
|
-
const SCROLLED_TO_BOTTOM_THRESHOLD_REMS =
|
|
40788
|
+
const SCROLLED_TO_BOTTOM_THRESHOLD_REMS = 1.5;
|
|
40795
40789
|
/*------------------------------------------------------------------------*/
|
|
40796
40790
|
/* -------------------------- Static Functions -------------------------- */
|
|
40797
40791
|
/*------------------------------------------------------------------------*/
|
|
@@ -40812,8 +40806,6 @@ var ActionType;
|
|
|
40812
40806
|
(function (ActionType) {
|
|
40813
40807
|
// Identify that the user is now scrolled to the bottom
|
|
40814
40808
|
ActionType["NowScrolledToBottom"] = "NowScrolledToBottom";
|
|
40815
|
-
// Identify that the user scrolled away from the bottom
|
|
40816
|
-
ActionType["NowScrolledAwayFromBottom"] = "NowScrolledAwayFromBottom";
|
|
40817
40809
|
// Identify that new content appeared at the bottom but is not visible
|
|
40818
40810
|
ActionType["NewContentAtBottom"] = "NewContentAtBottom";
|
|
40819
40811
|
})(ActionType || (ActionType = {}));
|
|
@@ -40827,20 +40819,11 @@ const reducer = (state, action) => {
|
|
|
40827
40819
|
switch (action.type) {
|
|
40828
40820
|
case ActionType.NowScrolledToBottom: {
|
|
40829
40821
|
return Object.assign(Object.assign({}, state), {
|
|
40830
|
-
// Store the event
|
|
40831
|
-
wasScrolledToBottom: true,
|
|
40832
40822
|
// Hide the "jump to bottom" button
|
|
40833
40823
|
jumpToBottomButtonVisible: false });
|
|
40834
40824
|
}
|
|
40835
|
-
case ActionType.NowScrolledAwayFromBottom: {
|
|
40836
|
-
return Object.assign(Object.assign({}, state), {
|
|
40837
|
-
// Store the event
|
|
40838
|
-
wasScrolledToBottom: false });
|
|
40839
|
-
}
|
|
40840
40825
|
case ActionType.NewContentAtBottom: {
|
|
40841
40826
|
return Object.assign(Object.assign({}, state), {
|
|
40842
|
-
// Store the event
|
|
40843
|
-
wasScrolledToBottom: false,
|
|
40844
40827
|
// Show the "jump to bottom" button
|
|
40845
40828
|
jumpToBottomButtonVisible: true });
|
|
40846
40829
|
}
|
|
@@ -40862,17 +40845,17 @@ const AutoscrollToBottomContainer = (props) => {
|
|
|
40862
40845
|
/* -------------- State ------------- */
|
|
40863
40846
|
// Initial state
|
|
40864
40847
|
const initialState = {
|
|
40865
|
-
wasScrolledToBottom: true,
|
|
40866
40848
|
jumpToBottomButtonVisible: false,
|
|
40867
40849
|
};
|
|
40868
40850
|
// Initialize state
|
|
40869
40851
|
const [state, dispatch] = React.useReducer(reducer, initialState);
|
|
40870
40852
|
// Destructure common state
|
|
40871
|
-
const {
|
|
40853
|
+
const { jumpToBottomButtonVisible, } = state;
|
|
40872
40854
|
/* -------------- Refs -------------- */
|
|
40873
40855
|
// Initialize refs
|
|
40874
40856
|
const lastItemIds = React.useRef([]);
|
|
40875
40857
|
const container = React.useRef(null);
|
|
40858
|
+
const wasScrolledToBottomBeforeItemsUpdate = React.useRef(true);
|
|
40876
40859
|
/*------------------------------------------------------------------------*/
|
|
40877
40860
|
/* ------------------------- Component Functions ------------------------ */
|
|
40878
40861
|
/*------------------------------------------------------------------------*/
|
|
@@ -40933,11 +40916,6 @@ const AutoscrollToBottomContainer = (props) => {
|
|
|
40933
40916
|
type: ActionType.NowScrolledToBottom,
|
|
40934
40917
|
});
|
|
40935
40918
|
}
|
|
40936
|
-
else {
|
|
40937
|
-
dispatch({
|
|
40938
|
-
type: ActionType.NowScrolledAwayFromBottom,
|
|
40939
|
-
});
|
|
40940
|
-
}
|
|
40941
40919
|
};
|
|
40942
40920
|
/*------------------------------------------------------------------------*/
|
|
40943
40921
|
/* ------------------------- Lifecycle Functions ------------------------ */
|
|
@@ -40951,7 +40929,7 @@ const AutoscrollToBottomContainer = (props) => {
|
|
|
40951
40929
|
scrollToBottom();
|
|
40952
40930
|
}, []);
|
|
40953
40931
|
/**
|
|
40954
|
-
* Update (also called on mount)
|
|
40932
|
+
* Update (also called on mount): autoscroll
|
|
40955
40933
|
* @author Gabe Abrams
|
|
40956
40934
|
*/
|
|
40957
40935
|
React.useEffect(() => {
|
|
@@ -40966,7 +40944,7 @@ const AutoscrollToBottomContainer = (props) => {
|
|
|
40966
40944
|
return;
|
|
40967
40945
|
}
|
|
40968
40946
|
// Check if used to be scrolled to the bottom
|
|
40969
|
-
if (
|
|
40947
|
+
if (wasScrolledToBottomBeforeItemsUpdate.current) {
|
|
40970
40948
|
// Was scrolled to the bottom! Autoscroll.
|
|
40971
40949
|
scrollToBottom();
|
|
40972
40950
|
}
|
|
@@ -40978,6 +40956,10 @@ const AutoscrollToBottomContainer = (props) => {
|
|
|
40978
40956
|
}
|
|
40979
40957
|
// Update last item ids
|
|
40980
40958
|
lastItemIds.current = currentItemIds;
|
|
40959
|
+
// Remember if we were scrolled to the bottom before the update
|
|
40960
|
+
return () => {
|
|
40961
|
+
wasScrolledToBottomBeforeItemsUpdate.current = isScrolledToBottom();
|
|
40962
|
+
};
|
|
40981
40963
|
}, [items]);
|
|
40982
40964
|
/*------------------------------------------------------------------------*/
|
|
40983
40965
|
/* ------------------------------- Render ------------------------------- */
|
|
@@ -40998,15 +40980,11 @@ const AutoscrollToBottomContainer = (props) => {
|
|
|
40998
40980
|
return (React__default["default"].createElement("div", { className: "AutoscrollToBottomContainer-outer-container" },
|
|
40999
40981
|
React__default["default"].createElement("style", null, style),
|
|
41000
40982
|
jumpToBottomButton,
|
|
41001
|
-
React__default["default"].createElement("div", { className: "AutoscrollToBottomContainer-scrollable-container", onScroll:
|
|
41002
|
-
handleScroll();
|
|
41003
|
-
}, ref: container }, items
|
|
40983
|
+
React__default["default"].createElement("div", { className: "AutoscrollToBottomContainer-scrollable-container", onScroll: handleScroll, ref: container }, items
|
|
41004
40984
|
// Render each item with a key
|
|
41005
40985
|
.map((item) => {
|
|
41006
40986
|
return (React__default["default"].createElement("div", { className: "AutoscrollToBottomContainer-item-container", key: item.id }, item.item));
|
|
41007
|
-
})
|
|
41008
|
-
// Reverse order because flex column is reverse
|
|
41009
|
-
.reverse())));
|
|
40987
|
+
}))));
|
|
41010
40988
|
};
|
|
41011
40989
|
|
|
41012
40990
|
/**
|