pixel-react 1.10.10-0 → 1.10.10-1
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/lib/components/Excel/ExcelFile/ExcelFile.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.esm.js +38 -9
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +38 -9
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Excel/ExcelFile/ExcelFile.tsx +1 -1
- package/src/components/TableTree/TableTree.stories.tsx +1 -0
- package/src/components/TableTree/TableTree.tsx +49 -13
package/lib/index.js
CHANGED
@@ -14879,7 +14879,9 @@ const TreeTable = ({
|
|
14879
14879
|
onAddCancel = () => {}
|
14880
14880
|
}) => {
|
14881
14881
|
const observerRef = React.useRef(null);
|
14882
|
-
const
|
14882
|
+
const isTriggeredAbove = React.useRef(false); // Track if pagination for "above" direction has been triggered
|
14883
|
+
const isTriggeredBelow = React.useRef(false); // Track if pagination for "below" direction has been triggered
|
14884
|
+
const isTriggeredOnce = React.useRef(false); // Ensure 2-second delay triggers only once
|
14883
14885
|
// Throttled version of loadMore
|
14884
14886
|
const throttledLoadMore = React.useRef(throttle(direction => {
|
14885
14887
|
loadMore(direction);
|
@@ -14892,19 +14894,25 @@ const TreeTable = ({
|
|
14892
14894
|
if (!scrollContainer || !firstNode || !lastNode || !treeData?.length) return;
|
14893
14895
|
const isLastResourceAbove = treeData[0]?.lastResource;
|
14894
14896
|
const isLastResourceBelow = treeData[treeData.length - 1]?.lastResource;
|
14897
|
+
// Skip pagination if both last resources are present
|
14895
14898
|
if (isLastResourceAbove && isLastResourceBelow) return;
|
14896
14899
|
const observerCallback = entries => {
|
14897
14900
|
entries.forEach(entry => {
|
14898
14901
|
const nodeId = entry.target.id;
|
14899
14902
|
const direction = nodeId === 'ff-table-tree-last-node' ? 'below' : 'above';
|
14900
14903
|
if (entry.isIntersecting) {
|
14901
|
-
|
14902
|
-
|
14903
|
-
|
14904
|
+
// Trigger only once for each direction
|
14905
|
+
if (direction === 'above' && !isTriggeredAbove.current) {
|
14906
|
+
if (!isLastResourceAbove) {
|
14907
|
+
throttledLoadMore(direction);
|
14908
|
+
isTriggeredAbove.current = true;
|
14909
|
+
}
|
14910
|
+
} else if (direction === 'below' && !isTriggeredBelow.current) {
|
14911
|
+
if (!isLastResourceBelow) {
|
14912
|
+
throttledLoadMore(direction);
|
14913
|
+
isTriggeredBelow.current = true;
|
14914
|
+
}
|
14904
14915
|
}
|
14905
|
-
} else {
|
14906
|
-
// Remove node from triggered set when it goes out of view
|
14907
|
-
triggeredNodesRef.current.delete(nodeId);
|
14908
14916
|
}
|
14909
14917
|
});
|
14910
14918
|
};
|
@@ -14913,8 +14921,29 @@ const TreeTable = ({
|
|
14913
14921
|
rootMargin: '8px',
|
14914
14922
|
threshold: 0.1
|
14915
14923
|
});
|
14916
|
-
if
|
14917
|
-
|
14924
|
+
// Initial pagination trigger after 2 seconds if first or last node is in view inside the scroll container
|
14925
|
+
const checkInitialPaginationTrigger = () => {
|
14926
|
+
if (isTriggeredOnce.current) return;
|
14927
|
+
const scrollContainerRect = scrollContainer.getBoundingClientRect();
|
14928
|
+
const firstNodeRect = firstNode?.getBoundingClientRect();
|
14929
|
+
const lastNodeRect = lastNode?.getBoundingClientRect();
|
14930
|
+
// Check if the first node is inside the scroll container
|
14931
|
+
const isFirstNodeInView = firstNodeRect && firstNodeRect.top >= scrollContainerRect.top && firstNodeRect.bottom <= scrollContainerRect.bottom;
|
14932
|
+
// Check if the last node is inside the scroll container
|
14933
|
+
const isLastNodeInView = lastNodeRect && lastNodeRect.top >= scrollContainerRect.top && lastNodeRect.bottom <= scrollContainerRect.bottom;
|
14934
|
+
if (isFirstNodeInView || isLastNodeInView) {
|
14935
|
+
isTriggeredOnce.current = true;
|
14936
|
+
setTimeout(() => {
|
14937
|
+
if (!isLastResourceAbove) observerRef.current?.observe(firstNode);
|
14938
|
+
if (!isLastResourceBelow) observerRef.current?.observe(lastNode);
|
14939
|
+
}, 2000); // Delay the first pagination trigger by 2 seconds
|
14940
|
+
} else {
|
14941
|
+
// Observe first and last node immediately
|
14942
|
+
if (!isLastResourceAbove) observerRef.current?.observe(firstNode);
|
14943
|
+
if (!isLastResourceBelow) observerRef.current?.observe(lastNode);
|
14944
|
+
}
|
14945
|
+
};
|
14946
|
+
checkInitialPaginationTrigger();
|
14918
14947
|
return () => {
|
14919
14948
|
observerRef.current?.disconnect();
|
14920
14949
|
throttledLoadMore.cancel();
|