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/esm/index.js CHANGED
@@ -40724,17 +40724,11 @@ const style = `
40724
40724
 
40725
40725
  .AutoscrollToBottomContainer-scrollable-container {
40726
40726
  /* Take up max 100% height, don't take it up if not needed */
40727
- /* (so column-reverse layout doesn't start at the bottom) */
40728
40727
  max-height: 100%;
40729
40728
  overflow-y: auto;
40730
40729
 
40731
40730
  /* Allow children to position */
40732
40731
  position: relative;
40733
-
40734
- /* Reverse order of children so scroll starts at bottom */
40735
- /* (but children will have to be rendered in reverse order) */
40736
- display: flex;
40737
- flex-direction: column-reverse;
40738
40732
  }
40739
40733
 
40740
40734
  .AutoscrollToBottomContainer-jump-to-bottom-container {
@@ -40765,7 +40759,7 @@ const style = `
40765
40759
  /*------------------------------------------------------------------------*/
40766
40760
  // Scrolled to bottom threshold
40767
40761
  // (how close you have to be to the bottom for it to count as the bottom)
40768
- const SCROLLED_TO_BOTTOM_THRESHOLD_REMS = 2;
40762
+ const SCROLLED_TO_BOTTOM_THRESHOLD_REMS = 1.5;
40769
40763
  /*------------------------------------------------------------------------*/
40770
40764
  /* -------------------------- Static Functions -------------------------- */
40771
40765
  /*------------------------------------------------------------------------*/
@@ -40786,8 +40780,6 @@ var ActionType;
40786
40780
  (function (ActionType) {
40787
40781
  // Identify that the user is now scrolled to the bottom
40788
40782
  ActionType["NowScrolledToBottom"] = "NowScrolledToBottom";
40789
- // Identify that the user scrolled away from the bottom
40790
- ActionType["NowScrolledAwayFromBottom"] = "NowScrolledAwayFromBottom";
40791
40783
  // Identify that new content appeared at the bottom but is not visible
40792
40784
  ActionType["NewContentAtBottom"] = "NewContentAtBottom";
40793
40785
  })(ActionType || (ActionType = {}));
@@ -40801,20 +40793,11 @@ const reducer = (state, action) => {
40801
40793
  switch (action.type) {
40802
40794
  case ActionType.NowScrolledToBottom: {
40803
40795
  return Object.assign(Object.assign({}, state), {
40804
- // Store the event
40805
- wasScrolledToBottom: true,
40806
40796
  // Hide the "jump to bottom" button
40807
40797
  jumpToBottomButtonVisible: false });
40808
40798
  }
40809
- case ActionType.NowScrolledAwayFromBottom: {
40810
- return Object.assign(Object.assign({}, state), {
40811
- // Store the event
40812
- wasScrolledToBottom: false });
40813
- }
40814
40799
  case ActionType.NewContentAtBottom: {
40815
40800
  return Object.assign(Object.assign({}, state), {
40816
- // Store the event
40817
- wasScrolledToBottom: false,
40818
40801
  // Show the "jump to bottom" button
40819
40802
  jumpToBottomButtonVisible: true });
40820
40803
  }
@@ -40836,17 +40819,17 @@ const AutoscrollToBottomContainer = (props) => {
40836
40819
  /* -------------- State ------------- */
40837
40820
  // Initial state
40838
40821
  const initialState = {
40839
- wasScrolledToBottom: true,
40840
40822
  jumpToBottomButtonVisible: false,
40841
40823
  };
40842
40824
  // Initialize state
40843
40825
  const [state, dispatch] = useReducer(reducer, initialState);
40844
40826
  // Destructure common state
40845
- const { wasScrolledToBottom, jumpToBottomButtonVisible, } = state;
40827
+ const { jumpToBottomButtonVisible, } = state;
40846
40828
  /* -------------- Refs -------------- */
40847
40829
  // Initialize refs
40848
40830
  const lastItemIds = useRef([]);
40849
40831
  const container = useRef(null);
40832
+ const wasScrolledToBottomBeforeItemsUpdate = useRef(true);
40850
40833
  /*------------------------------------------------------------------------*/
40851
40834
  /* ------------------------- Component Functions ------------------------ */
40852
40835
  /*------------------------------------------------------------------------*/
@@ -40907,11 +40890,6 @@ const AutoscrollToBottomContainer = (props) => {
40907
40890
  type: ActionType.NowScrolledToBottom,
40908
40891
  });
40909
40892
  }
40910
- else {
40911
- dispatch({
40912
- type: ActionType.NowScrolledAwayFromBottom,
40913
- });
40914
- }
40915
40893
  };
40916
40894
  /*------------------------------------------------------------------------*/
40917
40895
  /* ------------------------- Lifecycle Functions ------------------------ */
@@ -40925,7 +40903,7 @@ const AutoscrollToBottomContainer = (props) => {
40925
40903
  scrollToBottom();
40926
40904
  }, []);
40927
40905
  /**
40928
- * Update (also called on mount)
40906
+ * Update (also called on mount): autoscroll
40929
40907
  * @author Gabe Abrams
40930
40908
  */
40931
40909
  useEffect(() => {
@@ -40940,7 +40918,7 @@ const AutoscrollToBottomContainer = (props) => {
40940
40918
  return;
40941
40919
  }
40942
40920
  // Check if used to be scrolled to the bottom
40943
- if (wasScrolledToBottom) {
40921
+ if (wasScrolledToBottomBeforeItemsUpdate.current) {
40944
40922
  // Was scrolled to the bottom! Autoscroll.
40945
40923
  scrollToBottom();
40946
40924
  }
@@ -40952,6 +40930,10 @@ const AutoscrollToBottomContainer = (props) => {
40952
40930
  }
40953
40931
  // Update last item ids
40954
40932
  lastItemIds.current = currentItemIds;
40933
+ // Remember if we were scrolled to the bottom before the update
40934
+ return () => {
40935
+ wasScrolledToBottomBeforeItemsUpdate.current = isScrolledToBottom();
40936
+ };
40955
40937
  }, [items]);
40956
40938
  /*------------------------------------------------------------------------*/
40957
40939
  /* ------------------------------- Render ------------------------------- */
@@ -40972,15 +40954,11 @@ const AutoscrollToBottomContainer = (props) => {
40972
40954
  return (React__default.createElement("div", { className: "AutoscrollToBottomContainer-outer-container" },
40973
40955
  React__default.createElement("style", null, style),
40974
40956
  jumpToBottomButton,
40975
- React__default.createElement("div", { className: "AutoscrollToBottomContainer-scrollable-container", onScroll: () => {
40976
- handleScroll();
40977
- }, ref: container }, items
40957
+ React__default.createElement("div", { className: "AutoscrollToBottomContainer-scrollable-container", onScroll: handleScroll, ref: container }, items
40978
40958
  // Render each item with a key
40979
40959
  .map((item) => {
40980
40960
  return (React__default.createElement("div", { className: "AutoscrollToBottomContainer-item-container", key: item.id }, item.item));
40981
- })
40982
- // Reverse order because flex column is reverse
40983
- .reverse())));
40961
+ }))));
40984
40962
  };
40985
40963
 
40986
40964
  /**