dce-reactkit 3.5.8 → 3.5.10

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 CHANGED
@@ -40804,10 +40804,10 @@ const getItemIds = (items) => {
40804
40804
  // Types of actions
40805
40805
  var ActionType;
40806
40806
  (function (ActionType) {
40807
- // Identify that the user is now scrolled to the bottom
40808
- ActionType["NowScrolledToBottom"] = "NowScrolledToBottom";
40809
- // Identify that new content appeared at the bottom but is not visible
40810
- ActionType["NewContentAtBottom"] = "NewContentAtBottom";
40807
+ // Hide the "jump to bottom" button
40808
+ ActionType["HideJumpToBottomButton"] = "HideJumpToBottomButton";
40809
+ // Show the "jump to bottom" button
40810
+ ActionType["ShowJumpToBottomButton"] = "ShowJumpToBottomButton";
40811
40811
  })(ActionType || (ActionType = {}));
40812
40812
  /**
40813
40813
  * Reducer that executes actions
@@ -40817,15 +40817,11 @@ var ActionType;
40817
40817
  */
40818
40818
  const reducer = (state, action) => {
40819
40819
  switch (action.type) {
40820
- case ActionType.NowScrolledToBottom: {
40821
- return Object.assign(Object.assign({}, state), {
40822
- // Hide the "jump to bottom" button
40823
- jumpToBottomButtonVisible: false });
40820
+ case ActionType.HideJumpToBottomButton: {
40821
+ return Object.assign(Object.assign({}, state), { jumpToBottomButtonVisible: false });
40824
40822
  }
40825
- case ActionType.NewContentAtBottom: {
40826
- return Object.assign(Object.assign({}, state), {
40827
- // Show the "jump to bottom" button
40828
- jumpToBottomButtonVisible: true });
40823
+ case ActionType.ShowJumpToBottomButton: {
40824
+ return Object.assign(Object.assign({}, state), { jumpToBottomButtonVisible: true });
40829
40825
  }
40830
40826
  default: {
40831
40827
  return state;
@@ -40841,7 +40837,7 @@ const AutoscrollToBottomContainer = (props) => {
40841
40837
  /*------------------------------------------------------------------------*/
40842
40838
  /* -------------- Props ------------- */
40843
40839
  // Destructure all props
40844
- const { itemsName, items, jumpToBottomButtonVariant = Variant$1.Danger, } = props;
40840
+ const { itemsName, items, jumpToBottomButtonVariant = Variant$1.Danger, messageBeforeItems, messageAfterItems, } = props;
40845
40841
  /* -------------- State ------------- */
40846
40842
  // Initial state
40847
40843
  const initialState = {
@@ -40873,10 +40869,10 @@ const AutoscrollToBottomContainer = (props) => {
40873
40869
  return true;
40874
40870
  }
40875
40871
  // Get info about container
40876
- const { scrollTop, } = container.current;
40872
+ const { scrollTop, scrollHeight, clientHeight, } = container.current;
40877
40873
  // Distance to bottom
40878
40874
  const rootFontSizePx = Number.parseInt(getComputedStyle(document.documentElement).fontSize, 10);
40879
- const distanceToBottomRems = Math.abs(scrollTop / rootFontSizePx);
40875
+ const distanceToBottomRems = Math.abs((scrollTop + clientHeight - scrollHeight) / rootFontSizePx);
40880
40876
  // Figure out if we're scrolled to the bottom
40881
40877
  return (distanceToBottomRems < SCROLLED_TO_BOTTOM_THRESHOLD_REMS);
40882
40878
  };
@@ -40891,10 +40887,10 @@ const AutoscrollToBottomContainer = (props) => {
40891
40887
  }
40892
40888
  // Update state
40893
40889
  dispatch({
40894
- type: ActionType.NowScrolledToBottom,
40890
+ type: ActionType.HideJumpToBottomButton,
40895
40891
  });
40896
40892
  // Scroll to bottom
40897
- container.current.scrollTop = 0;
40893
+ container.current.scrollTop = container.current.scrollHeight;
40898
40894
  };
40899
40895
  /*----------------------------------------*/
40900
40896
  /* -------------- Handlers -------------- */
@@ -40908,12 +40904,10 @@ const AutoscrollToBottomContainer = (props) => {
40908
40904
  if (!container.current) {
40909
40905
  return;
40910
40906
  }
40911
- // Check if now scrolled to bottom
40912
- const nowScrolledToBottom = isScrolledToBottom();
40913
- // Remember if now no longer scrolled to bottom
40914
- if (nowScrolledToBottom) {
40907
+ // If scrolled to bottom, hide the button
40908
+ if (isScrolledToBottom()) {
40915
40909
  dispatch({
40916
- type: ActionType.NowScrolledToBottom,
40910
+ type: ActionType.HideJumpToBottomButton,
40917
40911
  });
40918
40912
  }
40919
40913
  };
@@ -40936,11 +40930,13 @@ const AutoscrollToBottomContainer = (props) => {
40936
40930
  // Check if new content appeared
40937
40931
  const currentItemIds = getItemIds(items);
40938
40932
  // Check if new content appeared at bottom
40939
- const newContentAtBottom = (currentItemIds.length > 0
40933
+ const newContentAppeared = (currentItemIds.length > 0
40934
+ && lastItemIds.current
40935
+ && lastItemIds.current.length > 0
40940
40936
  && (currentItemIds[currentItemIds.length - 1]
40941
40937
  !== lastItemIds.current[lastItemIds.current.length - 1]));
40942
40938
  // Do nothing if no new content
40943
- if (!newContentAtBottom) {
40939
+ if (!newContentAppeared) {
40944
40940
  return;
40945
40941
  }
40946
40942
  // Check if used to be scrolled to the bottom
@@ -40951,7 +40947,7 @@ const AutoscrollToBottomContainer = (props) => {
40951
40947
  else {
40952
40948
  // Not scrolled to bottom. Show "jump to bottom" button.
40953
40949
  dispatch({
40954
- type: ActionType.NewContentAtBottom,
40950
+ type: ActionType.ShowJumpToBottomButton,
40955
40951
  });
40956
40952
  }
40957
40953
  // Update last item ids
@@ -40980,11 +40976,14 @@ const AutoscrollToBottomContainer = (props) => {
40980
40976
  return (React__default["default"].createElement("div", { className: "AutoscrollToBottomContainer-outer-container" },
40981
40977
  React__default["default"].createElement("style", null, style),
40982
40978
  jumpToBottomButton,
40983
- React__default["default"].createElement("div", { className: "AutoscrollToBottomContainer-scrollable-container", onScroll: handleScroll, ref: container }, items
40984
- // Render each item with a key
40985
- .map((item) => {
40986
- return (React__default["default"].createElement("div", { className: "AutoscrollToBottomContainer-item-container", key: item.id }, item.item));
40987
- }))));
40979
+ React__default["default"].createElement("div", { className: "AutoscrollToBottomContainer-scrollable-container", onScroll: handleScroll, ref: container },
40980
+ messageBeforeItems,
40981
+ items
40982
+ // Render each item with a key
40983
+ .map((item) => {
40984
+ return (React__default["default"].createElement("div", { className: "AutoscrollToBottomContainer-item-container", key: item.id }, item.item));
40985
+ }),
40986
+ messageAfterItems)));
40988
40987
  };
40989
40988
 
40990
40989
  /**