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
package/dist/cjs/index.js
CHANGED
|
@@ -40733,35 +40733,31 @@ const idify = (str) => {
|
|
|
40733
40733
|
/**
|
|
40734
40734
|
* Container that automatically scrolls when new items are added,
|
|
40735
40735
|
* lets the user scroll up to see old items, but resumes
|
|
40736
|
-
* autoscroll when the user scrolls back to the bottom
|
|
40736
|
+
* autoscroll when the user scrolls back to the bottom.
|
|
40737
|
+
* Note: takes up full height of parent, so parent should
|
|
40738
|
+
* have a determined height for the scroll to work.
|
|
40737
40739
|
* @author Gabe Abrams
|
|
40738
40740
|
*/
|
|
40739
40741
|
/*------------------------------------------------------------------------*/
|
|
40740
40742
|
/* -------------------------------- Style ------------------------------- */
|
|
40741
40743
|
/*------------------------------------------------------------------------*/
|
|
40742
40744
|
const style = `
|
|
40743
|
-
.
|
|
40745
|
+
.AutoscrollToBottomContainer-outer-container {
|
|
40744
40746
|
/* Take up all space */
|
|
40745
40747
|
height: 100%;
|
|
40746
40748
|
position: relative;
|
|
40747
40749
|
}
|
|
40748
40750
|
|
|
40749
|
-
.
|
|
40751
|
+
.AutoscrollToBottomContainer-scrollable-container {
|
|
40750
40752
|
/* Take up max 100% height, don't take it up if not needed */
|
|
40751
|
-
/* (so column-reverse layout doesn't start at the bottom) */
|
|
40752
40753
|
max-height: 100%;
|
|
40753
40754
|
overflow-y: auto;
|
|
40754
40755
|
|
|
40755
40756
|
/* Allow children to position */
|
|
40756
40757
|
position: relative;
|
|
40757
|
-
|
|
40758
|
-
/* Reverse order of children so scroll starts at bottom */
|
|
40759
|
-
/* (but children will have to be rendered in reverse order) */
|
|
40760
|
-
display: flex;
|
|
40761
|
-
flex-direction: column-reverse;
|
|
40762
40758
|
}
|
|
40763
40759
|
|
|
40764
|
-
.
|
|
40760
|
+
.AutoscrollToBottomContainer-jump-to-bottom-container {
|
|
40765
40761
|
/* Don't take any space in parent */
|
|
40766
40762
|
height: 0;
|
|
40767
40763
|
overflow: visible;
|
|
@@ -40778,7 +40774,7 @@ const style = `
|
|
|
40778
40774
|
text-align: center;
|
|
40779
40775
|
}
|
|
40780
40776
|
|
|
40781
|
-
.
|
|
40777
|
+
.AutoscrollToBottomContainer-item-container {
|
|
40782
40778
|
/* Normal Height */
|
|
40783
40779
|
position: relative;
|
|
40784
40780
|
z-index: 1;
|
|
@@ -40789,7 +40785,7 @@ const style = `
|
|
|
40789
40785
|
/*------------------------------------------------------------------------*/
|
|
40790
40786
|
// Scrolled to bottom threshold
|
|
40791
40787
|
// (how close you have to be to the bottom for it to count as the bottom)
|
|
40792
|
-
const SCROLLED_TO_BOTTOM_THRESHOLD_REMS =
|
|
40788
|
+
const SCROLLED_TO_BOTTOM_THRESHOLD_REMS = 1.5;
|
|
40793
40789
|
/*------------------------------------------------------------------------*/
|
|
40794
40790
|
/* -------------------------- Static Functions -------------------------- */
|
|
40795
40791
|
/*------------------------------------------------------------------------*/
|
|
@@ -40810,8 +40806,6 @@ var ActionType;
|
|
|
40810
40806
|
(function (ActionType) {
|
|
40811
40807
|
// Identify that the user is now scrolled to the bottom
|
|
40812
40808
|
ActionType["NowScrolledToBottom"] = "NowScrolledToBottom";
|
|
40813
|
-
// Identify that the user scrolled away from the bottom
|
|
40814
|
-
ActionType["NowScrolledAwayFromBottom"] = "NowScrolledAwayFromBottom";
|
|
40815
40809
|
// Identify that new content appeared at the bottom but is not visible
|
|
40816
40810
|
ActionType["NewContentAtBottom"] = "NewContentAtBottom";
|
|
40817
40811
|
})(ActionType || (ActionType = {}));
|
|
@@ -40825,20 +40819,11 @@ const reducer = (state, action) => {
|
|
|
40825
40819
|
switch (action.type) {
|
|
40826
40820
|
case ActionType.NowScrolledToBottom: {
|
|
40827
40821
|
return Object.assign(Object.assign({}, state), {
|
|
40828
|
-
// Store the event
|
|
40829
|
-
wasScrolledToBottom: true,
|
|
40830
40822
|
// Hide the "jump to bottom" button
|
|
40831
40823
|
jumpToBottomButtonVisible: false });
|
|
40832
40824
|
}
|
|
40833
|
-
case ActionType.NowScrolledAwayFromBottom: {
|
|
40834
|
-
return Object.assign(Object.assign({}, state), {
|
|
40835
|
-
// Store the event
|
|
40836
|
-
wasScrolledToBottom: false });
|
|
40837
|
-
}
|
|
40838
40825
|
case ActionType.NewContentAtBottom: {
|
|
40839
40826
|
return Object.assign(Object.assign({}, state), {
|
|
40840
|
-
// Store the event
|
|
40841
|
-
wasScrolledToBottom: false,
|
|
40842
40827
|
// Show the "jump to bottom" button
|
|
40843
40828
|
jumpToBottomButtonVisible: true });
|
|
40844
40829
|
}
|
|
@@ -40850,7 +40835,7 @@ const reducer = (state, action) => {
|
|
|
40850
40835
|
/*------------------------------------------------------------------------*/
|
|
40851
40836
|
/* ------------------------------ Component ----------------------------- */
|
|
40852
40837
|
/*------------------------------------------------------------------------*/
|
|
40853
|
-
const
|
|
40838
|
+
const AutoscrollToBottomContainer = (props) => {
|
|
40854
40839
|
/*------------------------------------------------------------------------*/
|
|
40855
40840
|
/* -------------------------------- Setup ------------------------------- */
|
|
40856
40841
|
/*------------------------------------------------------------------------*/
|
|
@@ -40860,17 +40845,17 @@ const ScrollLockToBottom = (props) => {
|
|
|
40860
40845
|
/* -------------- State ------------- */
|
|
40861
40846
|
// Initial state
|
|
40862
40847
|
const initialState = {
|
|
40863
|
-
wasScrolledToBottom: true,
|
|
40864
40848
|
jumpToBottomButtonVisible: false,
|
|
40865
40849
|
};
|
|
40866
40850
|
// Initialize state
|
|
40867
40851
|
const [state, dispatch] = React.useReducer(reducer, initialState);
|
|
40868
40852
|
// Destructure common state
|
|
40869
|
-
const {
|
|
40853
|
+
const { jumpToBottomButtonVisible, } = state;
|
|
40870
40854
|
/* -------------- Refs -------------- */
|
|
40871
40855
|
// Initialize refs
|
|
40872
40856
|
const lastItemIds = React.useRef([]);
|
|
40873
40857
|
const container = React.useRef(null);
|
|
40858
|
+
const wasScrolledToBottomBeforeItemsUpdate = React.useRef(true);
|
|
40874
40859
|
/*------------------------------------------------------------------------*/
|
|
40875
40860
|
/* ------------------------- Component Functions ------------------------ */
|
|
40876
40861
|
/*------------------------------------------------------------------------*/
|
|
@@ -40931,11 +40916,6 @@ const ScrollLockToBottom = (props) => {
|
|
|
40931
40916
|
type: ActionType.NowScrolledToBottom,
|
|
40932
40917
|
});
|
|
40933
40918
|
}
|
|
40934
|
-
else {
|
|
40935
|
-
dispatch({
|
|
40936
|
-
type: ActionType.NowScrolledAwayFromBottom,
|
|
40937
|
-
});
|
|
40938
|
-
}
|
|
40939
40919
|
};
|
|
40940
40920
|
/*------------------------------------------------------------------------*/
|
|
40941
40921
|
/* ------------------------- Lifecycle Functions ------------------------ */
|
|
@@ -40949,7 +40929,7 @@ const ScrollLockToBottom = (props) => {
|
|
|
40949
40929
|
scrollToBottom();
|
|
40950
40930
|
}, []);
|
|
40951
40931
|
/**
|
|
40952
|
-
* Update (also called on mount)
|
|
40932
|
+
* Update (also called on mount): autoscroll
|
|
40953
40933
|
* @author Gabe Abrams
|
|
40954
40934
|
*/
|
|
40955
40935
|
React.useEffect(() => {
|
|
@@ -40964,7 +40944,7 @@ const ScrollLockToBottom = (props) => {
|
|
|
40964
40944
|
return;
|
|
40965
40945
|
}
|
|
40966
40946
|
// Check if used to be scrolled to the bottom
|
|
40967
|
-
if (
|
|
40947
|
+
if (wasScrolledToBottomBeforeItemsUpdate.current) {
|
|
40968
40948
|
// Was scrolled to the bottom! Autoscroll.
|
|
40969
40949
|
scrollToBottom();
|
|
40970
40950
|
}
|
|
@@ -40976,6 +40956,10 @@ const ScrollLockToBottom = (props) => {
|
|
|
40976
40956
|
}
|
|
40977
40957
|
// Update last item ids
|
|
40978
40958
|
lastItemIds.current = currentItemIds;
|
|
40959
|
+
// Remember if we were scrolled to the bottom before the update
|
|
40960
|
+
return () => {
|
|
40961
|
+
wasScrolledToBottomBeforeItemsUpdate.current = isScrolledToBottom();
|
|
40962
|
+
};
|
|
40979
40963
|
}, [items]);
|
|
40980
40964
|
/*------------------------------------------------------------------------*/
|
|
40981
40965
|
/* ------------------------------- Render ------------------------------- */
|
|
@@ -40986,25 +40970,21 @@ const ScrollLockToBottom = (props) => {
|
|
|
40986
40970
|
// Jump to Bottom button
|
|
40987
40971
|
let jumpToBottomButton;
|
|
40988
40972
|
if (jumpToBottomButtonVisible) {
|
|
40989
|
-
jumpToBottomButton = (React__default["default"].createElement("div", { className: `
|
|
40990
|
-
React__default["default"].createElement("button", { type: "button", className: `
|
|
40973
|
+
jumpToBottomButton = (React__default["default"].createElement("div", { className: `AutoscrollToBottomContainer-jump-to-bottom-container AutoscrollToBottomContainer-for-${idify(itemsName !== null && itemsName !== void 0 ? itemsName : 'items')}` },
|
|
40974
|
+
React__default["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" },
|
|
40991
40975
|
"New",
|
|
40992
40976
|
' ', itemsName !== null && itemsName !== void 0 ? itemsName : 'Content',
|
|
40993
40977
|
React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, { icon: freeSolidSvgIcons.faChevronDown, className: "ms-1" }))));
|
|
40994
40978
|
}
|
|
40995
40979
|
// Main UI
|
|
40996
|
-
return (React__default["default"].createElement("div", { className: "
|
|
40980
|
+
return (React__default["default"].createElement("div", { className: "AutoscrollToBottomContainer-outer-container" },
|
|
40997
40981
|
React__default["default"].createElement("style", null, style),
|
|
40998
40982
|
jumpToBottomButton,
|
|
40999
|
-
React__default["default"].createElement("div", { className: "
|
|
41000
|
-
handleScroll();
|
|
41001
|
-
}, ref: container }, items
|
|
40983
|
+
React__default["default"].createElement("div", { className: "AutoscrollToBottomContainer-scrollable-container", onScroll: handleScroll, ref: container }, items
|
|
41002
40984
|
// Render each item with a key
|
|
41003
40985
|
.map((item) => {
|
|
41004
|
-
return (React__default["default"].createElement("div", { className: "
|
|
41005
|
-
})
|
|
41006
|
-
// Reverse order because flex column is reverse
|
|
41007
|
-
.reverse())));
|
|
40986
|
+
return (React__default["default"].createElement("div", { className: "AutoscrollToBottomContainer-item-container", key: item.id }, item.item));
|
|
40987
|
+
}))));
|
|
41008
40988
|
};
|
|
41009
40989
|
|
|
41010
40990
|
/**
|
|
@@ -42887,6 +42867,7 @@ var DayOfWeek;
|
|
|
42887
42867
|
var DayOfWeek$1 = DayOfWeek;
|
|
42888
42868
|
|
|
42889
42869
|
exports.AppWrapper = AppWrapper;
|
|
42870
|
+
exports.AutoscrollToBottomContainer = AutoscrollToBottomContainer;
|
|
42890
42871
|
exports.ButtonInputGroup = ButtonInputGroup;
|
|
42891
42872
|
exports.CSVDownloadButton = CSVDownloadButton;
|
|
42892
42873
|
exports.CheckboxButton = CheckboxButton;
|
|
@@ -42919,7 +42900,6 @@ exports.PopPendingMark = PopPendingMark;
|
|
|
42919
42900
|
exports.PopSuccessMark = PopSuccessMark;
|
|
42920
42901
|
exports.RadioButton = RadioButton;
|
|
42921
42902
|
exports.ReactKitErrorCode = ReactKitErrorCode$1;
|
|
42922
|
-
exports.ScrollLockToBottom = ScrollLockToBottom;
|
|
42923
42903
|
exports.SimpleDateChooser = SimpleDateChooser;
|
|
42924
42904
|
exports.TabBox = TabBox;
|
|
42925
42905
|
exports.ToggleSwitch = ToggleSwitch;
|